package edu.colorado;

import edu.colorado.core.Game;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class PlayGameActivity extends Activity implements OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.play_game);
        
        View newGame = findViewById(R.id.newGameButton);
        View newTournament = findViewById(R.id.newTournamentButton);
        View resumeGame = findViewById(R.id.resumeGameButton);
        View resumeTournament = findViewById(R.id.resumeTournamentButton);
        
        newGame.setOnClickListener(this);
        newTournament.setOnClickListener(this);
        resumeGame.setOnClickListener(this);
        resumeTournament.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent next;
        
        switch (v.getId()) {
        case R.id.newGameButton:
            startActivity(new Intent(this, NewGameActivity.class));
            break;
        case R.id.newTournamentButton:
            next = new Intent(this, GameActivity.class);
            next.putExtra(GameActivity.MODE, Game.Mode.Tournament);
            next.putExtra(GameActivity.LEVEL, Game.Level.Easy);
            startActivity(next);
            break;
        case R.id.resumeGameButton:
            next = new Intent(this, GameActivity.class);
            next.putExtra(GameActivity.MODE, Game.Mode.Game);
            next.putExtra(GameActivity.SAVED_GAME, true);
            startActivity(next);
            break;
        case R.id.resumeTournamentButton:
            next = new Intent(this, GameActivity.class);
            next.putExtra(GameActivity.MODE, Game.Mode.Tournament);
            next.putExtra(GameActivity.SAVED_TOURNAMENT, true);
            startActivity(next);
            break;
        }
    }
}